package guet.dream.qa;


import static org.junit.Assert.*;
import guet.dream.question.QuestionDaoImpl;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class QuestionAnswerDaoImplTest {

	private QuestionAnswerDaoImpl quAnswerDao;
	private QuestionDaoImpl questionDao;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		quAnswerDao = new QuestionAnswerDaoImpl();
		questionDao = new QuestionDaoImpl();
	}

	@Test
	public void testSaveAnswerOfQuestion(){
		int qid = 1;
		String content = "PreparedStatement主要注意下其中set方法的使用及resultset的使用,that is it!";
		int  size_old = questionDao.findAnswersByQuestionId(qid).size();
		int count = quAnswerDao.saveAnswerByQuestionId(qid,content);
		int size_new = questionDao.findAnswersByQuestionId(qid).size();
		
		assertEquals(1,count);
		assertEquals(size_old+1,size_new);
		
	}
}
